package com.springIOC.config;

import com.springIOC.bean.Bean5;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.NamespaceHandler;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

/**
 * Created by mike on 18/5/11.
 */
public class TestNamespaceHandler implements NamespaceHandler{
    @Override
    public void init() {
        System.out.println("TestNamespaceHandler init");
    }

    @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        NamedNodeMap namedNodeMap = element.getAttributes();
        BeanDefinition beanDefinition = new RootBeanDefinition(Bean5.class);
        parserContext.getRegistry().registerBeanDefinition("xsdBean",beanDefinition);
        return null;
    }

    @Override
    public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder beanDefinitionHolder, ParserContext parserContext) {
        return null;
    }
}
